package logic

import (
	"context"
	"house_srv/houseclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AminHouseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAminHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AminHouseLogic {
	return &AminHouseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AminHouseLogic) AminHouse(req *types.AminHouseHouseRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	sms, err := l.svcCtx.HouseRpc.AminHouse(l.ctx, &houseclient.AminHouseHouseRequest{
		HouseId:     int64(req.HouseId),
		HouseStatus: int64(req.HouserStatus),
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "上架成功",
		Code:    200,
		Data:    sms,
	}, nil
}
